﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class modify_table_StdFormDict : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainStdFormDict_MainProductTopic_TopicDictId",
                table: "MainStdFormDict");

            migrationBuilder.RenameColumn(
                name: "TopicDictId",
                table: "MainStdFormDict",
                newName: "ProductTopicId");

            migrationBuilder.RenameColumn(
                name: "SchemaJson",
                table: "MainStdFormDict",
                newName: "Schema");

            migrationBuilder.RenameIndex(
                name: "IX_MainStdFormDict_TopicDictId",
                table: "MainStdFormDict",
                newName: "IX_MainStdFormDict_ProductTopicId");

            migrationBuilder.AlterColumn<string>(
                name: "Mode",
                table: "MainStdFormDict",
                type: "text",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "text");

            migrationBuilder.AlterColumn<string>(
                name: "Layout",
                table: "MainStdFormDict",
                type: "text",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "text");

            migrationBuilder.AddColumn<string>(
                name: "ConcurrencyStamp",
                table: "MainStdFormDict",
                type: "character varying(40)",
                maxLength: 40,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<Guid>(
                name: "DeleterId",
                table: "MainStdFormDict",
                type: "uuid",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "DeletionTime",
                table: "MainStdFormDict",
                type: "timestamp with time zone",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "ExtraProperties",
                table: "MainStdFormDict",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<bool>(
                name: "IsDeleted",
                table: "MainStdFormDict",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddForeignKey(
                name: "FK_MainStdFormDict_MainProductTopic_ProductTopicId",
                table: "MainStdFormDict",
                column: "ProductTopicId",
                principalTable: "MainProductTopic",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainStdFormDict_MainProductTopic_ProductTopicId",
                table: "MainStdFormDict");

            migrationBuilder.DropColumn(
                name: "ConcurrencyStamp",
                table: "MainStdFormDict");

            migrationBuilder.DropColumn(
                name: "DeleterId",
                table: "MainStdFormDict");

            migrationBuilder.DropColumn(
                name: "DeletionTime",
                table: "MainStdFormDict");

            migrationBuilder.DropColumn(
                name: "ExtraProperties",
                table: "MainStdFormDict");

            migrationBuilder.DropColumn(
                name: "IsDeleted",
                table: "MainStdFormDict");

            migrationBuilder.RenameColumn(
                name: "Schema",
                table: "MainStdFormDict",
                newName: "SchemaJson");

            migrationBuilder.RenameColumn(
                name: "ProductTopicId",
                table: "MainStdFormDict",
                newName: "TopicDictId");

            migrationBuilder.RenameIndex(
                name: "IX_MainStdFormDict_ProductTopicId",
                table: "MainStdFormDict",
                newName: "IX_MainStdFormDict_TopicDictId");

            migrationBuilder.AlterColumn<string>(
                name: "Mode",
                table: "MainStdFormDict",
                type: "text",
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Layout",
                table: "MainStdFormDict",
                type: "text",
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_MainStdFormDict_MainProductTopic_TopicDictId",
                table: "MainStdFormDict",
                column: "TopicDictId",
                principalTable: "MainProductTopic",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
